using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using Xyne.CardManagement;

namespace Xyne.Utilities
{
    public class DeckManager
    {
        public static Deck GetDeck(string deckName)
        {
            CardPack pack = new CardPack();
            XmlSerializer serializer = new XmlSerializer(pack.GetType());
            FileStream stream = new FileStream(@"Packs\"+deckName+"Deck.xml", FileMode.Open, FileAccess.Read);
            pack = serializer.Deserialize(stream) as CardPack;
            stream.Close();

            // Generate a couple cards from the pack
            Deck tempDeck = new Deck();
            foreach (CardData card in pack.Cards)
            {
                
                    CardData newCard = new CardData(card);
                    for (int i = 0; i < newCard.Actions.Count; i++)
                    {
                        //       newCard.Actions[i].InitializeActualObjects();

                        //      if (newCard.Actions[i].OnCollision != null)
                        //          newCard.Actions[i].OnCollision.Action.InitializeActualObjects();
                    }
                    tempDeck.GetCards().Enqueue(newCard);
                
            }
            tempDeck.Name = deckName;
            return tempDeck;
        }
    }
}
